package main

import "fmt"
import "os"

func isComplete(n int) bool {
	sum := 0
	for i := 2; i < n; i++ {
		if n%i == 0 {
			sum += i
		}
	}
	if sum == n {
		return true
	} else {
		return false
	}
}
func WriteFile(path string) {
	f, err := os.Create(path)
	if err != nil {
		fmt.Println("打开文件异常")
		return
	}
	fmt.Println("输出判断到completenumbers.txt....")
	for i := 2; i <= 10000; i++ {
		if isComplete(i) == true {
			fmt.Println("i=", i)
			buf := fmt.Sprintf("i=%d\n", i)
			f.WriteString(buf)
		} else {
			continue
		}
	}
	fmt.Println("输出完毕")
	defer f.Close()
}
func main() {
	path := "../target/completenumbers.txt"
	WriteFile(path)
}
